package cn.xuqiudong.console.config.sso;

import cn.xuqiudong.sso.client.filter.LoginFilter;
import cn.xuqiudong.sso.common.constant.SsoConstant;
import cn.xuqiudong.sso.common.model.RpcAccessToken;
import cn.xuqiudong.sso.common.model.SsoUser;

import java.util.function.Consumer;

/**
 * 描述:
 *
 * @author Vic.xu
 * @since 2024-06-19 11:09
 */
public class SsoTest {
    public static void main(String[] args) {
        LoginFilter loginFilter = new LoginFilter();
        //前后端分离的登录过滤器
//        SeparationLoginFilter loginFilter = new SeparationLoginFilter(clientHost, htmlUrl);

        //登录成功之后的回调
        Consumer<RpcAccessToken> afterLogin = accessToken -> {
            System.out.println(accessToken.getUser().getId());
        };
        loginFilter.setAfterLogin(afterLogin);

        RpcAccessToken rpcAccessToken = new RpcAccessToken();
        rpcAccessToken.setAccessToken("123");
        rpcAccessToken.setExpiresIn(1000);
        rpcAccessToken.setRefreshToken("123");
        SsoUser user = new SsoUser();
        user.setId("123");
        rpcAccessToken.setUser(user);

        afterLogin.accept(rpcAccessToken);
    }
}
